/*************************************************************************
 *                                                                       *
 * This file is part of the FreeMAPs distribution.  For full copyright   *
 * information, see COPYRIGHT and COPYING.LESSER.                        *
 *                                                                       *
 * Author:           sqbang                                              *
 * Email:            sqbang@ustc.edu                                     *
 * Date:             2016.03.24                                          *
 *                                                                       *
 *************************************************************************/

//declaration header
#include "COMMON/bdry/DistributedLoadBoundaryCondition.h"

//COMMON headers
#include "COMMON/equa/PDEEquationEnsembleStrategy.h"
#include "COMMON/equa/EquationDomain.h"
#include "COMMON/info/InfoManager.h"
#include "COMMON/info/CommonInfo.h"
#include "COMMON/tbox/LogMessage.h"
#include "COMMON/tbox/Utilities.h"


namespace FreeMAPs
{

DistributedLoadBoundaryCondition::DistributedLoadBoundaryCondition (
    const std::string& parent_name,
    const std::string& bc_name,
    const PDEEquationEnsembleStrategy* equation_ensemble) :
    Parent (parent_name, bc_name, equation_ensemble)
{}



DistributedLoadBoundaryCondition::~DistributedLoadBoundaryCondition ()
{
    this->clear();
}



void
DistributedLoadBoundaryCondition::clear()
{
    //Utilities::clear_pointer_object (d_para_load);
}



void
DistributedLoadBoundaryCondition::get_info_for_derived_object_from_input (
    const InputDatabase* db)
{
#if 0
    this->prepare_for_use (db);

    const int dim = InfoManager::get_instance()->get_common_info()->get_dim();

    db->insert_allowable_key ("para_load_x");
    db->insert_allowable_key ("para_load_y");

    if (dim == 3)
    {
        db->insert_allowable_key ("para_load_z");
    }

    db->check_allowable_keys();

    /*
     * build para_load_i
     */
    d_para_load.resize (dim);
    for (int i = 0; i < dim; ++i)
    {
        const std::string para_name = "para_load_" + Utilities::int_to_axis (i);
        d_para_load[i] = new Function (this->get_full_name(), para_name);
        db->check_requisite_key (para_name, DataType::UNKNOWN, false, false);
        d_para_load[i]->get_from_input (
            db,
            para_name,
            InfoManager::get_instance()->get_variable_info(),
            InfoManager::get_instance()->get_function_info());

        d_para_load[i]->attach_region (this->get_equation_ensemble()->get_equation_domain()->get_region());
        d_para_load[i]->set_used_flag();
    }
#endif
}



std::string
DistributedLoadBoundaryCondition::get_info_from_derived_object() const
{
    std::ostringstream os, oss;

    os << "physical_parameters\n{";
#if 0

    for (std::size_t i = 0; i < d_para_load.size(); ++i)
    {
        oss << '\n' << *d_para_load[i];
    }
#endif

    os << LogMessage::get_log_info (oss, ONE_TAB) << '\n';
    os << "}";

    return os.str();
}

} // namespace FreeMAPs
